﻿<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="my.myorm.tool.jdbc.SQLExecutor" %>
<%@ page import="my.myorm.tool.jdbc.ResultList" %>
<%@ page import="my.myorm.tool.jdbc.SQLManager" %>
<%@ page import="com.mtbu.bean.SysUser" %>
<%@ page import="com.util.SuperString" %>
<%@ page import="com.mtbu.bean.SysModule" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@page import="com.util.DESUtil"%>
<%@page import="com.mtbu.comm.Util"%>
<%@include file="sys_commcheck.jsp"%>
<%
    String permission = "";
    String strModuleID_menu = "";
    String strModuleID_item = "";

    SQLExecutor dbconn = SQLManager.getSQLExecutor();
    String sql = "select permission from sys_user where username=?";
    dbconn.addParam(Constant_UserName);
    SysUser user = dbconn.queryForBean(sql, SysUser.class);
    if(user != null) {
        permission = user.getPermission();
    }
    while(permission.indexOf(",,") >= 0) {
        permission = SuperString.replace(permission, ",,", ",");
    }
    if(permission.startsWith(",")) permission = permission.substring(1);
    if(permission.endsWith(",")) permission = permission.substring(0, permission.length() - 1);

    strModuleID_item = permission;
    strModuleID_item = SuperString.replace(strModuleID_item, ",", "','");
    strModuleID_item = "'" + strModuleID_item + "'";

    String[] arrModuleID = permission.split(",");
    if(arrModuleID == null) arrModuleID = new String[]{};
    for(int i = 0; i < arrModuleID.length; i++) {
        if(arrModuleID[i].length() > 0) {
            String _MID = arrModuleID[i].substring(0, arrModuleID[i].indexOf("-"));
            if(strModuleID_menu.indexOf("'" + _MID + "'") < 0)
                strModuleID_menu += (strModuleID_menu.length() > 0 ? "," : "") + "'" + _MID + "'";
        }
    }
    if(strModuleID_menu.length() == 0) strModuleID_menu = "''";

    sql = "select * from sys_module where parentid='0' and status<>2 and moduleid in (" + strModuleID_menu + ") " +
            "order by moduleid";
    ResultList list = dbconn.query(sql, false, null);

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>PPLive 媒资管理系统</title>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/HoverAccordion.js" type="text/javascript"></script>
<link href="css/adminPPLive.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">  
$(document).ready(function(){  
    $('#leftmenu').hoverAccordion({  
      activateitem: '1',  
      speed: 'fast',
      onClickOnly : true  
    });  
    $(".leftlinkmenu").click(function(){
        $(".leftlinkhover").removeClass("leftlinkhover");
		$(this).find("a").addClass("leftlinkhover");
    });
});  
function swapMenu(isscoll){
	var height = $("#leftmenu").css("height").replace("px","");
    if(isscoll && height<1000){
    	parent.document.getElementById('mainframeset').cols="176,10,*";
	}else{
		parent.document.getElementById('mainframeset').cols="160,10,*";	
	}
}
</script> 
</head>
<body style="overflow-x:hidden">
<div style="background-image: url(images/adminMenuBgSpan.gif);">
<ul id="leftmenu">  
	<%
    for(int j = 0; j < list.size(); j++) {
        SysModule module=list.get(j).get(SysModule.class);   
        sql="select * from sys_module where parentid='"+module.getModuleID()+"' and status<>2 " +
	        "and moduleid in ("+strModuleID_item+") " +
	        "order by moduleid";
		ResultList sublist=dbconn.query(sql,false,null);
    %>
    <li><h1 class="type"><a href="javascript:void(0)" onmouseup="swapMenu(<%=sublist.size()>15?"true":"false"%>)" style="color: #000000;"><%=module.getModuleName()%></a></h1>
        <ul>
	        <li>
	        	<ul class="adminLeftMenu">
	        		<div><img src="images/adminMenuTopLine.gif" width="160" height="5" /></div>
	        		<%
		            for(int i = 0; i < sublist.size(); i++) {
		                module=sublist.get(i).get(SysModule.class);
		                String _moduleid =module.getModuleID();
		                String _modulename =module.getModuleName();
		                String _link =module.getLink()+(module.getLink().indexOf("?")>0?"&":"?")+"mid="+Util.encodeUrl(DESUtil.encodeString(_moduleid,Util.getProperties("CONST_DES_KEY")));
               		%>
					<%if(_modulename.indexOf("-------------")>=0){%><div style="height: 11px;width: 160px;"></div><%}else{%><li class="leftlinkmenu" ><a href="<%=_link%>" target="mainFrame"><%=_modulename%></a></li><%}%>					
					<%}%>				
				</ul>
			</li>
		</ul>  
    </li>      
    <%}%>
</ul>  
</div>
</body>
</html>
